﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Trangtrai.CauhinhController;
using Trangtrai.Controller.Global;

namespace Trangtrai.cauhinhsanxuat
{
    public partial class Food : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            ctrpage1.Visible = true;
            table.Visible = true;
            btnSave.Visible = true;
            table1.Visible = true;
            btnSave2.Visible = true;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            FoodController.InsertFoodSeperate(2, tbxFoodCode.Text, tbxName.Text, tbxNote.Text);
            if (cbxCode1.SelectedIndex > -1 && tbxUnit1.Text != null)
            {
                FoodController.InsertFoodMix(tbxFoodCode.Text, cbxCode1.Text, float.Parse(tbxUnit1.Text));
            }
            if (cbxCode2.SelectedIndex > -1 && tbxUnit2.Text != null)
            {
                FoodController.InsertFoodMix(tbxFoodCode.Text, cbxCode1.Text, float.Parse(tbxUnit2.Text));
            }
            if (cbxCode3.SelectedIndex > -1 && tbxUnit3.Text != null)
            {
                FoodController.InsertFoodMix(tbxFoodCode.Text, cbxCode1.Text, float.Parse(tbxUnit3.Text));
            }
            Response.Redirect("~/cauhinh/Food.aspx");
        }


        protected void btnSave2_Click(object sender, EventArgs e)
        {
            FoodController.InsertFoodSeperate(1, tbxFoodCodeSe.Text, tbxFoodNameSe.Text, tbxNoteSe.Text);
        }
    }
}
